package com.banyuan.课堂练习.Thread;

import java.util.concurrent.Callable;

public class Demo2 implements Callable {

    private int start;
    private int end;

    public Demo2(int start, int end) {
        System.out.println("创建了一个线程！");
        this.start = start;
        this.end = end;
    }

    @Override
    public Object call() throws Exception {
        int sum = 0;
        for (int i = start; i <= end; i++) {
            sum += i;
            System.out.println(Thread.currentThread() + "-" + sum);
        }
        return sum;
    }
}
